﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ERPStore.Web.Extensions;

using CloudSoft.Extensions;

namespace ERPStore.NewsLetters.Models
{
    public class NewsLetterSource : ERPStore.Models.LeadSourceBase
    {
        public override string Id
        {
            get { return "BCD6FCFE-21B6-4211-A8F6-D5F633D88A6A"; }
        }

        public override string Name
        {
            get { return "NewsLetter"; }
        }

        public override string Description
        {
            get { return "NewsLetter ERPStore"; }
        }

		public override string TrackSourceId
		{
			get { return "newsletter"; }
		}

		public override string Medium
		{
			get { return "organic"; }
		}

		public override ERPStore.Models.LeadSourceType LeadSourceType
		{
			get { return ERPStore.Models.LeadSourceType.Emailing; }
		}

        public override bool Match(Uri sourceUri, Uri landingUri, out string keywords, out string subHost, out decimal amount)
        {
			keywords = string.Empty; // sourceUri.GetSearchKeywords();
            subHost = null;
            amount = 0;
			var landingPrms = landingUri.GetParameters();
            if (landingPrms.AllKeys.Contains("estid"))
            {
                var estid = landingPrms["estid"];
                if (estid.StartsWith("nl", StringComparison.InvariantCultureIgnoreCase))
                {
					if (landingPrms.AllKeys.Contains("utm_campaign"))
					{
						subHost = landingPrms["utm_campaign"];
					}
                    return true;
                }
            }

            return false;
        }

    }
}
